<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>Dojox Recorder Test</title>

	<style>
		@import "../../../dojo/resources/dojo.css";
		@import "../../../dijit/tests/css/dijitTests.css";
	</style>

	<!-- required: the default dijit theme: -->
	<link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/tundra/tundra.css">

	<!-- required: dojo.js -->
	<script type="text/javascript" src="../../../dojo/dojo.js"
		djConfig="isDebug: true, parseOnLoad: true"></script>

	<!-- only needed for alternate theme testing: -->
	<script type="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>

	<script type="text/javascript">
		dojo.require("dijit.dijit");
		dojo.require("dijit.form.ComboBox");
		dojo.require("dijit.robot");
		dojo.require("dojox.robot.recorder");
		dojo.addOnLoad(function(){
			doh.register('dojox.robot.AutoGeneratedTestGroup',{
				// would be nice to have Deferred support for setUp/tearDown
				name: 'setUp',
				timeout: 5100,
				runTest: function(){
					var d = new doh.Deferred();
					// start the recorder and close the alert
					dojo.byId('textbox').value="";
					doh.robot.mouseMoveAt('safeclick');
					doh.robot.mouseClick({left:true, middle:false, right:false}, 3);
					doh.robot.keyPress(dojo.keys.ENTER, 3000,null,true);
					doh.robot.keyPress(dojo.keys.ENTER, 1000,{ctrl:true,alt:true});
					setTimeout(function(){
						d.callback(true);
					},5000);
					return d;
				}
			});
			doh.register('dojox.robot.AutoGeneratedTestGroup',{
				name: 'autotest0',
				timeout: 8879,
				runTest: function(){
					var d = new doh.Deferred();
					// Safari/Mac stops listening to mouse movement after the alert pops up in the runner
					// click to wake it up
					doh.robot.mouseMoveAt('safeclick');
					doh.robot.mouseClick({left:true, middle:false, right:false});
					doh.robot.mouseMove(196, 124, 353,true);
					doh.robot._scrollIntoView('widget_combo');
					doh.robot.mouseMoveAt(dijit.byId('combo').downArrowNode, 18, 100, 1, 7);
					doh.robot.mouseClick({left:true, middle:false, right:false}, 1);
					doh.robot.mouseMove(195, 124, 546,true);
					doh.robot.mouseMove(174, 165, 16,true);
					doh.robot.mouseMoveAt('combo_popup2', 483, 100, 148, 5);
					doh.robot.mouseClick({left:true, middle:false, right:false}, 1);
					doh.robot.mouseMove(155, 195, 334,true);
					doh.robot.mouseMoveAt('textbox', 331, 100, 131, 11);
					doh.robot.mouseClick({left:true, middle:false, right:false}, 1);
					doh.robot.typeKeys('test me', 602, 1500);
					doh.robot.keyPress(dojo.keys.ENTER, 500,{ctrl:true,alt:true});
					doh.robot.sequence(function(){
						var div=dojo.byId('dojox.robot.recorder');
						var text;
						if(div["innerText"] !== undefined){
							text = div.innerText;
						}else if(div["textContent"]){
							text = div.textContent;
						}
						var re = new RegExp
("MoveAt.*Click.*Move.*scrollIntoView.*MoveAt.*Click.*Move\\(.*MoveAt.*Click.*Move\\(.*MoveAt.*Click.*typeKeys");
						if(re.test(text.replace(/[\n\r\t]/g))){
							d.callback(true);
						}else{
							d.errback(new Error('We got a failure'));
						}
					}, 1000);
					return d;
				}
			});

			doh.run();
		});
	</script>
</head>
<body class="tundra">
<h1 id="safeclick">Recorder will use the DOH robot to record a test by itself.</h1>
<p>dijit.form.ComboBox:</p>
<select dojoType="dijit.form.ComboBox" id="combo">
<option>A</option>
<option>B</option>
<option>C</option>
</select>
<p>Native element:</p>
<input type="text" id="textbox">
</body>
</html>
